"""my_blog URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.views.generic import RedirectView
# 新引入的模块
from django.conf import settings
from django.conf.urls.static import static
from django.urls import re_path
from django.views.static import serve


urlpatterns = [
    # 主页
    path('', RedirectView.as_view(url='article/article-list/')),
    # path('api/auth/qq', admin.site.urls),

    # 外部url
    path('admin/', admin.site.urls),
    path('password-reset/', include('password_reset.urls')),

    # 本地url
    path('api/', include('api.urls', namespace='api')),     # auth

    path('article/', include('article.urls', namespace='article')),
    path('userprofile/', include('userprofile.urls', namespace='userprofile')),
    path('comment/', include('comment.urls', namespace='comment')),
    path('test_view/', include('test_view.urls', namespace='test_view')),
    # path('comment/', include(('comment.urls', 'comment'), namespace='comment')),
    # re_path(settings.STATIC_ROOT + '(?P<path>.*)', serve, {"document_root": settings.STATIC_ROOT}),  # 静态文件模块
]

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

